package org.cargloss.cp.controller.modul.ourcustomer;

import org.cargloss.cp.model.OurCustomer;

import util.hibernate.DAO;

import com.opensymphony.xwork2.ActionSupport;

public class ActionCrud extends ActionSupport {
	private static final long serialVersionUID = -5933849517817526086L;
	private String id;
	private String fileName;
	private String url;
	private int orderBy;

	public String insert() {
		DAO<Integer> dao = new DAO<Integer>();
		OurCustomer object = new OurCustomer();

		object.setLogo(getFileName());
		object.setOrderBy(getOrderBy());
		object.setUrl(getUrl());
		dao.insert(object);
		dao.close();
		return "empty";
	}

	public String update() {
		DAO<Integer> dao = new DAO<Integer>();

		OurCustomer object = (OurCustomer) dao.find(OurCustomer.class,
				Integer.valueOf(getId()));

		object.setLogo(getFileName());
		object.setOrderBy(getOrderBy());
		object.setUrl(getUrl());

		dao.update(object);
		dao.close();
		return "empty";
	}

	public String delete() {
		DAO<Integer> dao = new DAO<Integer>();
		OurCustomer delete = (OurCustomer) dao.find(OurCustomer.class,
				Integer.valueOf(getId()));

		dao.delete(delete);
		dao.close();
		return "empty";
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public int getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(int orderBy) {
		this.orderBy = orderBy;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

}
